package com.baihan.angus.app.game.busshow.pop_dialog;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.baihan.angus.app.game.busshow.R;
import com.baihan.angus.app.game.common.data_center.cache.GameCache;

public class ChatAndCluePopup extends PopupWindow {

    private OnSelectListener mOnSelectListener;
    private TextView tvSearchEvidence, tvPrivateChat;

    public ChatAndCluePopup(Context context, int type, OnSelectListener mOnSelectListener) {
        super(context);
        this.mOnSelectListener = mOnSelectListener;

        View contentView = LayoutInflater.from(context).inflate(R.layout.chat_and_clue_popup, null);
        setContentView(contentView);
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setOutsideTouchable(true);
        // 设置PopupWindow是否能响应点击事件
        setTouchable(true);
        setFocusable(true);

        tvSearchEvidence = contentView.findViewById(R.id.tvSearchEvidence);
        tvPrivateChat = contentView.findViewById(R.id.tvPrivateChat);

        if (!TextUtils.isEmpty(GameCache.currentStage) && GameCache.currentStage.equals("搜证阶段")) {
            tvSearchEvidence.setVisibility(View.VISIBLE);
        } else {
            tvSearchEvidence.setVisibility(View.GONE);
        }

        tvSearchEvidence.setOnClickListener(view -> {
            if (mOnSelectListener != null) mOnSelectListener.onSelect(1);
        });

        tvPrivateChat.setOnClickListener(view -> {
            if (mOnSelectListener != null) mOnSelectListener.onSelect(2);
        });
    }

    public interface OnSelectListener {
        void onSelect(int type);//1-搜证 2-私聊
    }
}
